#version 110

varying vec4 couleur;
varying vec3 N,L,V;

void main(){



	 float intensiteDiffus;
	 float spec, coef;
     vec3 R;
	 
     N=gl_NormalMatrix*gl_Normal;
     L=gl_LightSource[0].position.xyz;
	 V = vec3(-gl_ModelViewMatrix*gl_Vertex);

     L=normalize(L);
     N=normalize(N);
	 V=normalize(V);
     intensiteDiffus = max(dot(N,L),0.0);
	
	 
	 R = 2.0*(dot(N,L))*N - L;
	 R=normalize(R);
	 
	 coef=max(dot(V,R),0.0);
	 spec = pow(coef,gl_FrontMaterial.shininess);

     couleur=(intensiteDiffus *gl_FrontMaterial.diffuse) + (spec*gl_FrontMaterial.specular);

     gl_Position = gl_ProjectionMatrix*gl_ModelViewMatrix*gl_Vertex;
}
